#ifndef SRAUDIOTHREAD_H
#define SRAUDIOTHREAD_H

#include <QThread>
#include <mutex>
#include <list>


#include "ffmpeg.h"
#include "SrDecode.h"
#include "SrResample.h"
#include "SrAudioPlay.h"


class SrAudioThread:public QThread
{
public:
    SrAudioThread();
    virtual ~SrAudioThread();

    virtual bool Open(AVCodecParameters *codecpar, int sampleRate, int channels);

    // 清理资源, 停止线程
    virtual void Close();

    // 清理队列
   virtual void Clear();


    virtual void Push(AVPacket *pkt);

    //线程
    void run();

public:
    int _maxList = 100; // 最大队列
    bool _isExit = false;

    long long audio_cur_pts = 0; // 当前解码到的pts

private:
    SrDecode *m_audio_decode;
    SrResample *m_audio_resample;
    SrAudioPlay *m_audio_a_play;

    std::list<AVPacket *> _packs;
    std::mutex _mux;

};

#endif // SRAUDIOTHREAD_H
